Repository navigation
Add hidraw backend for FreeBSD - #730
Conversation
|
Currently, some stuff like the Report Descriptor parser and error registry routine are copied from Linux and I think they are platform independent. Can we create a common directory or hidraw directory in code then put them inside? Have tested by the hidtest program. |
49a7a62 to
6e7a25a
Compare
|
Thanks for @Youw your review:). Then, What is your opinion about this?
|
I thinjk that is a good idea, but I don't think it really is nesessary to do so in scope of this PR. |
|
Nice. This will address the following issue. |
|
Oops. I forget we have udev-devd stuff. Maybe we should use udev also? |
I lost context here. What for? Seem like you have all the functionality implemented already. Aren't you? |
Yes, all functionality is fully implemented. I am just thinking if we should use libudev make hidapi more portable. |
|
First test under FreeBSD 14.1 Release, under a physical machine (Chuwi mini PC, Intel J4125 CPU, 8GB RAM, 256GB SSD) There are a few compiler warnings. |
|
Fix it:). Forget to fix the warning. |
|
Somehow hidtest-hidraw will seg fault with the Microchip Simple HID example. |
Thanks. The compiler warnings are gone. The Segfault issue is still there though. |
Using Ventoy and then I can do that. Interesting findings -- now FreeBSD 15.0 Release and OpenBSD 7.9 can boot and I have installed them to the second SATA SSDs of the two Intel N100 Mini PCs. Somehow I need to use HTTP install. For the FreeBSD 16.0-Current images (your version or the snapshot version), both will fail to boot. All in all, looks like the issue is related to file system corruption. Screen photo taken from my mobile phone.
|
Assisted-by: codex:gpt-5
|
I've used gpt5.6-sol and found a number of issues with this implementation. |
Resolve the build-system conflicts with current master, fix the FreeBSD backend review findings, and add comprehensive native-backend CI including installed CMake export consumers. Assisted-by: codex:gpt-5 Assisted-by: claude-code:claude-fable-5
Use explicit zeroing for FreeBSD ioctl structures and keep parser locals outside cleanup jumps so the warnings-as-errors C++ CI build succeeds. Assisted-by: codex:gpt-5
|
Codex updated the PR branch and pushed a186873:
Validation completed locally across Autotools, CMake shared/static, Meson, pkg-config, and installed export consumers. All PR checks are now green, including the native FreeBSD job and AppVeyor. Generated by Codex (GPT-5). |
|
Now someone could test and tell if there anything else left to fix - that would be helpful to move this forward. |
Yes I will test over the weekend. |
Sorry I was busy. I will try to do it this weekend or next week. |
Sorry for the late reply. It looks good for me! Thanks! |
|
Tested latest PR under FreeBSD 15.1 Relese VM using Vitualbox under Windows 11. This PR does not work whereas PR728 works. So probably the EHCI fix is not included in the FreeBSD 15.1 release. |
Once I force the VM to use OHCI (USB Full Speed), this PR works fine. |
|
@Youw |
| set(HIDAPI_PC_INSTALL_DIR "libdata/pkgconfig") | ||
| else() | ||
| set(HIDAPI_PC_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}/pkgconfig") |
There was a problem hiding this comment.
just wounder why can't this be handled by settings CMAKE_INSTALL_LIBDIR to libdata before calling hidapi_configure_pc for freebsd
Preserve Linux libdl linkage and FreeBSD libusb requirements in both pkg-config generators. Integrates the FreeBSD backend from libusb#730. Assisted-by: codex:gpt-6
Wake blocked readers with a nonblocking pipe and preserve sticky interrupt state without adding read/write-path locks. Release wake descriptors on failed opens and close. Add hardware-free lifecycle tests and run them in the native FreeBSD C, static and C++ builds. Document the test's scope and configure ASan for FreeBSD targets. Related to #799 and #730. Assisted-by: Codex:GPT-6
Wake blocked readers with a nonblocking pipe and preserve sticky interrupt state without adding read/write-path locks. Release wake descriptors on failed opens and close. Add hardware-free lifecycle tests and run them in the native FreeBSD C, static and C++ builds. Document the test's scope and configure ASan for FreeBSD targets. Related to #799 and #730. Assisted-by: Codex:GPT-6
Add the FreeBSD hidraw setter, preserve read interruption, and size libusb ring slots for descriptor-sized input reports. Move the shared ring and top-level tests under src, updating build, packaging and documentation references. Extend queue and virtual-device regression checks. Related to libusb#154, libusb#274, libusb#728, libusb#730 and libusb#799. Assisted-by: Codex:gpt-6
Add hid_set_num_input_buffers() across all backends, including FreeBSD hidraw, and share a preallocated input ring between macOS and libusb. Preserve large input reports and read interruption, release resources on initialization failure, and clear device errors after successful setters. Move core/ and tests/ under src/ and update build, distribution, CI, documentation and comment references. Extend queue and virtual-device coverage for validation and resizing. Related to #154. Related to #274. Related to #728. Related to #730. Related to #799. Co-authored-by: Ihor Dutchak <ihor.youw@gmail.com> Assisted-by: Claude Code CLI:claude-opus-4.6 Assisted-by: Claude Code CLI:claude-opus-4.7 Assisted-by: Codex CLI:gpt-5.4 Assisted-by: Codex:gpt-6 Assisted-by: Codex:gpt-6-astra Assisted-by: Claude Code:claude-fable-5-1

FreeBSD support hidraw in Kernel from 13.0.
By using libusb only, we can only see the HID device from usb. To address this, we implement hidraw backend for FreeBSD.
Just like Linux use libudev to handle usb specified HID stuff (like Manufacture), we use libusb to handle it.
Sponsored-by: FreeBSD Foundation
Related to #274
Fixes #543
Assisted-by: codex:gpt-5